<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box {
        width: 100px;
        height: 100px;
        border: 1px solid black;
    }

    .box1 {
        width: 50px;
        height: 50px;
        border: 1px solid black;
    }

    .cc {
        background-color: red;
    }
</style>

<body>
    <div class="box">
    </div>
    <div class="box1"></div>

    <script>
        const box = document.querySelector('.box')
        const box1 = document.querySelector('.box1')
        box.addEventListener('click', function (e) {
            box1.classList.remove('cc')
            box.classList.add('cc')
        })
        box1.addEventListener('click', function () {
            box.classList.remove('cc')
            box1.classList.add('cc')
        })

    </script>
</body>

</html>